import LocalizedStrings from 'react-native-localization';
import { en } from '@/localization/en';
import { zh } from '@/localization/zh';

const useLocalization = () => {
  let defaultLang = 'zh';

  const setLang = (lang) => (defaultLang = lang);

  const getLang = () => defaultLang;

  return {
    getLang,
    setLang,
  };
};

const { getLang, setLang } = useLocalization();

const langObj = {
  zh: new LocalizedStrings({ zh }),
  en: new LocalizedStrings({ en }),
};

export const strings = function () {
  return langObj[getLang()];
};

export { getLang, setLang };
